Exposing .NET enums to COM clients{VBScript}

Posted by Codex on Stack Overflow See other posts from Stack Overflow or by Codex
Published on 2010-04-12T18:24:44Z Indexed on 2010/04/15 12:13 UTC
Read the original article Hit count: 497

Filed under:
|
|
|
|

Am trying create of PoC for exposing/invoking various .NET objects from COM clients. The .NET library contains some classes and Enums.

Am able to successfully access the classes in VBScript but not able to access the Enums. I know that Enums are value types and hence 'CreateObject' wont work in this case.

But am able to access the same Enum in VBA code.

Questions:

  • How can I access the enums in VBScript?

  • Why does the behaviour differ in the two COM clients? If VBA object browser can see the enum, why cant VBScript allow me to create one?

.NET

  [ComVisible(true)]
[GuidAttribute("ebc25cf6-9120-4283-b972-0e5520d0000E")]        
public enum Currency
{        
    GBP = CurrencyConvertorBL.CurrencyConvertorRef.Currency.GBP,        
    USD = CurrencyConvertorBL.CurrencyConvertorRef.Currency.USD,        
    INR = CurrencyConvertorBL.CurrencyConvertorRef.Currency.INR,
    AUD = CurrencyConvertorBL.CurrencyConvertorRef.Currency.AUD
}

VBA

    Private Function ConvertCurrency(fromCurrency As Currency, 
toCurrency As Currency) As Double

VBScript ???

Set currencyConvertorCCY = CreateObject("CurrencyConvertorBL.Currency")

Thanks in advance.

© Stack Overflow or respective owner

Related posts about com

Related posts about interop